﻿using Microsoft.Xna.Framework;

namespace SomeGame.Actors.Components {

    public class Body : ActorComponent {

        private Vector2 position;
        public Vector2 Position {
            get { return position; }
            set {
                position = value;
                Bounds.X = (int)position.X;
                Bounds.Y = (int)position.Y;
            }
        }
        private int width;
        public int Width {
            get { return width; }
            set {
                width = value;
                Bounds.Width = width;
            }
        }
        private int height;
        public int Height {
            get { return height; }
            set {
                height = value;
                Bounds.Height = height;
            }
        }
        public float LayerDepth; // This isn't the SpriteBatch LayerDepth, this is used for parallax calculation.
        public FacingDirection FacingDirection;
        public Rectangle Bounds;
        public float Scale;

        public Body(float positionX, 
                    float positionY, 
                    int width = 0, 
                    int height = 0, 
                    float scale = 1f, 
                    float layerDepth = 1f, 
                    FacingDirection facingDirection = FacingDirection.Right) {
            Position = new Vector2(positionX, positionY);
            LayerDepth = layerDepth;
            FacingDirection = facingDirection;
            Scale = scale;
            Bounds = new Rectangle((int)positionX, (int)positionY, (int)(width*scale), (int)(height*scale));
        }

	    public override void Update(GameTime gameTime, bool parallax) {
		    if (parallax) {
                Position += ((GameEngine.Camera.PositionDelta/LayerDepth)-GameEngine.Camera.PositionDelta)*-1;
		    }
	    }

    }

    public enum FacingDirection {

        Left,
        Right

    }

}